package com.example.demo.controller;

import com.example.demo.dao.RedisDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redis")
public class RedisTestController {
    private static final Logger log = LoggerFactory.getLogger(RedisTestController.class);
    @Autowired
    RedisDao redisDao;
    @GetMapping("/set")
    public String setKey(){
        try {
            redisDao.setKey("name", "wangweiliang");
            redisDao.setKey("age", "18");
            redisDao.setKey("address", "和润幸福城");
            log.info(redisDao.getValue("name"));
            log.info(redisDao.getValue("age"));
            log.info(redisDao.getValue("address"));
            return "success";
        } catch (Exception e) {
            return e.getMessage();
        }
    }
}
